/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package reportcenter.report.dominio.column;

import reportcenter.report.dominio.report.Report;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import reportcenter.report.dominio.InterfaceFluente;

/**
 *
 * @author renan_luz
 */
@Entity
@Table(name = "REPORT_COLUM")
@NamedQueries({@NamedQuery(name = "ReportColum.findByIdRc", query = "SELECT r FROM ReportColum r WHERE r.idRc = :idRc"), @NamedQuery(name = "ReportColum.findByColumnName", query = "SELECT r FROM ReportColum r WHERE r.columnName = :columnName"), @NamedQuery(name = "ReportColum.findByColumnDescr", query = "SELECT r FROM ReportColum r WHERE r.columnDescr = :columnDescr")})
public class ReportColum implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "ID_RC", nullable = false)
    private Integer idRc;
    
    @Column(name = "COLUMN_NAME", nullable = false)
    private String columnName;
    
    @Column(name = "COLUMN_DESCR", nullable = false)
    private String columnDescr;
    
    @JoinColumn(name = "ID_R", referencedColumnName = "ID_R")
    @ManyToOne
    private Report idR;
    
    @Column(name = "CLAZZ", nullable = false)
    private String clazz;
    
    @Column(name = "WIDTH", nullable= false)
    private Integer width;

    public ReportColum() {
    }
    
    public static InterfaceFluenteReportColum criarCom() {
        return InterfaceFluente.create(
                new ReportColum(), InterfaceFluenteReportColum.class);
    }

    public ReportColum(Integer idRc) {
        this.idRc = idRc;
    }

    public ReportColum(Integer idRc, String columnName, String columnDescr) {
        this.idRc = idRc;
        this.columnName = columnName;
        this.columnDescr = columnDescr;
    }

    public Integer getIdRc() {
        return idRc;
    }

    public void setIdRc(Integer idRc) {
        this.idRc = idRc;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getColumnDescr() {
        return columnDescr;
    }

    public void setColumnDescr(String columnDescr) {
        this.columnDescr = columnDescr;
    }

    public Report getIdR() {
        return idR;
    }

    public void setIdR(Report idR) {
        this.idR = idR;
    }

    public String getClazz() {
        return clazz;
    }

    public void setClazz(String clazz) {
        this.clazz = clazz;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRc != null ? idRc.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ReportColum)) {
            return false;
        }
        ReportColum other = (ReportColum) object;
        if ((this.idRc == null && other.idRc != null) || (this.idRc != null && !this.idRc.equals(other.idRc))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.ReportColum[idRc=" + idRc + "]";
    }

}
